package com.ruoyi.activiti.until;

public class ResponseDTO<T> {
    //返回的状态：1=成功；0=失败；-1=程序异常
    private Integer success;
    //提示信息
    private String msg;
    //返回的数据
    private T data;

    public ResponseDTO(Integer success, String msg, T data) {
        this.success = success;
        this.msg = msg;
        this.data = data;
    }

    /**
     * 操作成功
     * @param msg
     * @return
     */
    public static ResponseDTO success(String msg){

        return new ResponseDTO(1,msg,null);
    }

    /**
     * 操作成功
     * @param msg
     * @param data
     * @param <T>
     * @return
     */
    public static <T> ResponseDTO success(String msg, T data){

        return new ResponseDTO(1,msg,data);
    }

    /**
     * 操作失败
     * @param msg
     * @return
     */
    public static ResponseDTO fail(String msg){

        return new ResponseDTO(0,msg,null);
    }

    /**
     * 程序异常
     * @param msg
     * @return
     */
    public static ResponseDTO error(String msg){

        return new ResponseDTO(-1,msg,null);
    }


    public Integer getSuccess() {
        return success;
    }

    public void setSuccess(Integer success) {
        this.success = success;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
